<template>
  <div class="personalSettingRealName_container pr-1 pl-1">
		<div class="personalSettingRealName_container_item  pt-0 pb-0 pl-1 pr-1 br-16 mb-0" v-for="(item,index) in list" :key="index" @click="goItem(item.id)">
			<img class="setting_img" :src="item.image" alt="">
				<div class="item_content">
					<div class="item_content_left">
						<div class="item_content_left_title">{{item.title}}</div>
						<div class="item_content_left_label" v-if="!!item.label">{{item.label}}</div>
					</div>
					<img class="item_content_icon" src="@/image/aiQuantization/indexTop/arrow.png" alt=""/>
				</div>
		</div>
  </div>
</template>

<script>
import { getUserInfo } from "@/request/personalCenter"
export default {
    name : "PersonalSettingRealName",
		data(){
			return{
				userInfo:{
					phoneNumber: "",
					livingBills: '',
					identity: '',
					tax: ''	
				},
				list:[]
			}
		},
		mounted(){
			this.getUserRealNameInfo()
		},
		methods:{
			getUserRealNameInfo(){
				// 在此请求用户认证数据
				console.log(this.$route.params.id)
				getUserInfo().then(res=>{
					if(res.code == 1){
						this.userInfo = {
							phoneNumber: res.data.phone,
							livingBills: res.data.is_life,
							identity: res.data.is_shiming,
							tax: res.data.is_tax
						}
					}
					this.disposeList()
				})
			},
			disposeList(){
				// 处理列表
				this.list = [
					{
						id:1,
						title: this.$t("手机号码"),
						image: require("@/image/personalCenter/setting/realName/verified3.png"),
						label: !!this.userInfo.phoneNumber? this.$t("已认证") : this.$t("待上传"),
					},
					{
						id:3,
						title: this.$t("生活账单"),
						image: require("@/image/personalCenter/setting/realName/verified5.png"),
						label:this.userInfo.livingBills == 2? this.$t("已认证") : this.userInfo.livingBills == 1? this.$t("审核中") : this.$t("待上传"),
					},
					{
						id:2,
						title: this.$t("手持身份证"),
						image: require("@/image/personalCenter/setting/realName/verified4.png"),
						label:this.userInfo.identity == 2 ? this.$t("已认证") : this.userInfo.identity == 1 ? this.$t("审核中") : this.$t("待上传"),
					},
					{
						id:4,
						title: this.$t("税务申请"),
						image: require("@/image/personalCenter/setting/realName/verified5.png"),
						label:this.userInfo.tax == 2? this.$t("已认证") : this.userInfo.tax == 1 ? this.$t("审核中") : this.$t("待上传"),
					},
				]
			},
			goItem(id){
				// 跳转到具体的认证页面
				if(this.$route.name != 'PersonalSettingAuthentication'){
					sessionStorage.setItem('personalSettingRealName', id) // 认证类型
					sessionStorage.setItem('personalSettingName', 1) // 用户id
					this.$router.push({
						name: 'PersonalSettingAuthentication',
						params:{
							id: 1, // 传递用户id
							type: id, // 认证类型
						}
					})
				}
			}
		}
};
</script>

<style>
</style>